Skip to content

Conversation

simosho
Copy link

@simosho simosho commented Nov 22, 2024

addresses #62

@@ -93,7 +93,7 @@ module.exports = fp(
if (raw.socket.destroyed) {
throw new Errors.SOCKET_CLOSED(reqId)
} else {
raw.once(
raw.socket.once(
'close',
function () {
if (controllers.has(this)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried checking if the request was completed by doing

Suggested change
if (controllers.has(this)) {
if (!raw.completed && controllers.has(this)) {

but that doesn't seem to work as intended for a http1.1 client like unidici.

Do we need some other check, as i'm not sure if it will work for http2 clients, as they can close their sending side of the socket while keeping the receiving side open?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is a must, otherwise we can abort the request as soon as the transmission has finished (request payload received and parsed).

A keep-alive connection is independent of a request lifecycle; the keep alive is handled by the socket while the request lifecycle by the IncomingMessage API (or HTTPServerRequest for HTTP/2).

Let's add it, I believe your tests already covers these cases. Maybe one more for HTTP/2 can be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requests with multipart/form-data flagged as aborted immediately after payload consumed
2 participants